import { useRef } from "react"

/**
 * 永远返回最新的值
 * @param value 要处理的值
 * @returns
 */
const useLatest = <T>(value: T): { readonly current: T } => {
  const ref = useRef(value)
  ref.current = value
  return ref
}

export default useLatest
